#!/bin/sh
#
# chkconfig: - 86 14
# description: IP45 daemon
# processname: ip45d
#

### BEGIN INIT INFO
# Provides: ip45d
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 1 2 3 4 5 
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Start and stop ip45 daemon
# Description:  IP45daemon, http://ip45.org
### END INIT INFO


# IP45 Project - http://ip45.org
#
# Copyright (C) 2012 - 2014,  Tomas Podermanski
#
# This code can be redistributed and/or modified under the terms of 
# the GNU General Public License as published by the Free Software 
# Foundation, either version 3 of the License, or (at your option) 
# any later version, see <http://www.gnu.org/licenses/>.



# Source function library.
. /etc/rc.d/init.d/functions

exec=/usr/sbin/ip45d
prog=${exec##*/}
lockfile=/var/lock/subsys/ip45d

start()
{
    echo -n $"Starting ip45d: "
    daemon $exec -D 
    rv=$?
    echo
    [ $rv -eq 0 ] && touch $lockfile
    return $rv
}

stop()
{
    echo -n $"Shutting down ip45d: "
    killproc $prog
    rv=$?
    echo
    [ $rv -eq 0 ] && rm -f $lockfile
    return $rv
}

restart()
{
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    force-reload)
        restart
        ;;
    status)
        status $prog
        ;;
    try-restart|condrestart)
        if status $prog >/dev/null ; then
            restart
        fi
        ;;
    reload)
        action $"Service ${0##*/} does not support the reload action: " /bin/false
        exit 3
        ;;
    *)
	echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
	exit 2
	;;
esac

